package com.hexinfo.dmpro.data.disaster.recovery.backups.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hexinfo.dmpro.data.disaster.recovery.backups.model.DisasterRecoveryList;
import com.hexinfo.dmpro.data.disaster.recovery.backups.service.DisasterRecoveryListService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;


/**
 * 生产数据灾备任务明细表
 *
 * @author wz.li
 * @date 2023-10-09 18:57:44
 */
@RestController
@AllArgsConstructor
@RequestMapping("/api/disasterrecoverylist")
@Api(value = "disasterrecoverylist", tags = "生产数据灾备任务明细表管理")
public class DisasterRecoveryListController {

    private final DisasterRecoveryListService disasterRecoveryListService;

    /**
     * 分页查询
     *
     * @param page                 分页对象
     * @param disasterRecoveryList 生产数据灾备任务明细表
     *                             WrapperEnhancer.like(disasterRecoveryList); //自动拼接存在值sql的方法
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page")
    public ResponseEntity<Object> getDisasterRecoveryListPage(Page page, DisasterRecoveryList disasterRecoveryList) {
        return ResponseEntity.ok(disasterRecoveryListService.queryList(page, disasterRecoveryList));
    }


    /**
     * 通过id查询生产数据灾备任务明细表
     *
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}")
    public ResponseEntity<Object> getById(@PathVariable("id") String id) {
        return ResponseEntity.ok(disasterRecoveryListService.getById(id));
    }

    /**
     * 新增生产数据灾备任务明细表
     *
     * @param disasterRecoveryList 生产数据灾备任务明细表
     * @return R
     */
    @ApiOperation(value = "新增生产数据灾备任务明细表", notes = "新增生产数据灾备任务明细表")
    @PostMapping
    public ResponseEntity<Object> save(@RequestBody DisasterRecoveryList disasterRecoveryList) {
        return ResponseEntity.ok(disasterRecoveryListService.save(disasterRecoveryList));
    }

    /**
     * 修改生产数据灾备任务明细表
     *
     * @param disasterRecoveryList 生产数据灾备任务明细表
     * @return R
     */
    @ApiOperation(value = "修改生产数据灾备任务明细表", notes = "修改生产数据灾备任务明细表")
    @PutMapping
    public ResponseEntity<Object> updateById(@RequestBody DisasterRecoveryList disasterRecoveryList) {
        return ResponseEntity.ok(disasterRecoveryListService.updateById(disasterRecoveryList));
    }

    /**
     * 通过id删除生产数据灾备任务明细表
     *
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除生产数据灾备任务明细表", notes = "通过id删除生产数据灾备任务明细表")
    @DeleteMapping("/{id}")
    public ResponseEntity<Object> removeById(@PathVariable String id) {
        return ResponseEntity.ok(disasterRecoveryListService.removeById(id));
    }

}
